package com.lmx.persistence.service;

import org.springframework.stereotype.Service;

import com.lmx.common.util.CommonUtil;
import com.lmx.persistence.service.common.BaseCrudServiceImpl;
import com.lmx.repoDomain.tmodel.CustomerBusinessFlow;

/**
 * TODO(用一句话描述该文件做什么)
 *
 * @author ytche
 * @date 2018年5月20日
 *
 */
@Service(value = "CustomerBusinessFlowService")
public class CustomerBusinessFlowServiceImpl extends BaseCrudServiceImpl<CustomerBusinessFlow>
		implements CustomerBusinessFlowService {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.lmx.persistence.service.common.BaseCrudService#save(com.lmx.repoDomain
	 * .tmodel.BaseDataEntity)
	 */
	@Override
	public int findCountCustomerBusinessFlow(Long tenantId) {
		String time = null;// 前天日期
		Integer timeStart = null;
		Integer timeEnd = null;
		try {
			time = CommonUtil.getCurrTimeForString();// 前天日期
			timeStart = CommonUtil.strToIntegerTime(time.substring(0, 10) + " 00:00:00");
			timeEnd = CommonUtil.strToIntegerTime(time.substring(0, 10) + " 23:59:59");
		} catch (Exception e) {
			// logger.debug("create OldMan stat error :" + e);
		}
		String queryStr = "from CustomerBusinessFlow as cf where cf.delStatus=0 and cf.tenant.id= :tenantId and "
				+ "cf.createDateTime >= :startTime " + " and cf.createDateTime <:endTime";
		int count = super.em.createQuery(queryStr).setParameter("tenantId", tenantId)
				.setParameter("startTime", timeStart).setParameter("endTime", timeEnd)
				.getResultList().size();
		return count;
	}

}
